
<!DOCTYPE html>
<html>
<head>
<title>基本设置</title>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
<link rel="stylesheet" href="../../css/bootstrap.min.css">
<link rel="stylesheet" href="../../css/font-awesome.min.css">
<link rel="stylesheet" href="../../plugins/jqgrid/ui.jqgrid-bootstrap.css">
<link rel="stylesheet" href="../../plugins/ztree/css/metroStyle/metroStyle.css">
<link rel="stylesheet" href="../../css/main.css">
<!-- <link rel="stylesheet" href="../../css/button.css"> -->
<script src="../../libs/jquery.min.js"></script>
<script src="../../plugins/layer/layer.js"></script>
<script src="../../libs/bootstrap.min.js"></script>
<script src="../../libs/vue.min.js"></script>
<script src="../../libs/validator.min.js"></script>
<script src="../../plugins/jqgrid/grid.locale-cn.js"></script>
<script src="../../plugins/jqgrid/jquery.jqGrid.min.js"></script>
<script src="../../plugins/ztree/jquery.ztree.all.min.js"></script>
<script src="../../js/common.js"></script>

<script src="../../plugins/jquery-validation/jquery.validate.min.js"></script>
<script src="../../plugins/jquery-validation/jquery.validate.addMethod.js"></script>
</head>
<body>
	<form class="form-horizontal" id="form">
		<!-- 一个隐藏的input  存放id -->
		<input type="hidden" id="id" name="id" >
		<div class="form-group">
		   	<div class="col-sm-2 control-label">全盘手续费设置:</div>
		   	<div class="col-sm-7">
		     <input type="hidden" class="form-control form-tip"  name="id" id="id"/>
		     <input type="text" class="form-control form-tip"  name="charge" id="charge"/>
		    </div>
		</div>
		<div class="form-group">
			<div class="col-sm-2 control-label"></div> 
			<input type="button" class="btn btn-primary settingbtn"  value="提交"/>
		</div>
	</form>
<script src="../../js/modules/sys/charge.js"></script>
<script >
function validform(){
	  /*关键在此增加了一个return，返回的是一个validate对象，这个对象有一个form方法，返回的是是否通过验证*/
	  return $("#form").validate({
	     rules : {
	    	 charge: {
                  required: true,
                  maxlength: 5,
                  costratio: true
        		}
	
	        },
	        messages : {
	        	charge: {
                  required: '请填写全盘手续费设置',
                  maxlength: '最多输入5个字符'
         		}
	        }
	  });
	}
	//注册表单验证
	$(validform());
	//以上部分已经实现匿名函数的作用，下面介绍如何通过普通按钮实现表单验证
	$(".settingbtn").click(function(){
	    if(validform().form()) {
	    	var id = $("input[name=id]").val();
	    	var charge = $("input[name=charge]").val();
	    	$.ajax({
	    		type:"post",
	    		url:baseURL + 'sys/charge/saveorupdate',
	    		data:{"id":id,"charge":charge},
	    		success:function(r){
	    			if(r.code == 0){
	    				alert('操作成功', function(){
	    					window.location.reload();
	    				});
	    			}else{
	    				alert(r.msg);
	    			}
	    		},
	    	});
	    } else {
	        //校验不通过，什么都不用做，校验信息已经正常显示在表单上
	    }
	});

/* $(".settingbtn").click(function(){
	var id = $("input[name=id]").val();
	var isopen = $("select[name=isopen]").val();
	var webname = $("input[name=webname]").val();
	var costdesu = $("input[name=costdesu]").val();
	var minorderamount = $("input[name=minorderamount]").val();
	var maxorderamount = $("input[name=maxorderamount]").val();
	var maxuseramount = $("input[name=maxuseramount]").val();
	$.ajax({
		type:"post",
		url:baseURL + 'sys/settings/update',
		data:{"id":id,"isopen":isopen,"webname":webname,"costdesu":costdesu,"minorderamount":minorderamount,"maxorderamount":maxorderamount,"maxuseramount":maxuseramount},
		success:function(r){
			if(r.code == 0){
				alert('操作成功', function(){
					window.location.reload();
				});
			}else{
				alert(r.msg);
			}
		},
	}); 
}) */
</script>
</body>
</html>